export default {
  getAssembleData(businessModule, fileName) {
    let context = require.context('@/business', true, /\.js$/);
    let exportData = {};
    if (context && context.keys) {
      context.keys().forEach(key => {
        let needAssemble = true;
        const pathName = key.split('/');
        if (businessModule && businessModule.length) {
          const moudules = businessModule.split('/');
          for (let i = 0; i < moudules.length; i++) {
            needAssemble = moudules[i] === pathName[i + 1];
          }
        }
        if (needAssemble && fileName && fileName.length) {
          if (fileName.indexOf('.js') === -1) {
            fileName += '.js';
          }
          needAssemble = pathName[pathName.length - 1] === fileName;
        }
        if (needAssemble) {
          const data = context(key).default;
          Object.assign(exportData, data);
        }
      });
    }
    return exportData;
  }
}
